package akjvm.tools.java.classpath;

import java.io.File;
import java.io.IOException;

/**
 * Created by VictoryWang on 2016/6/22.
 */
public abstract class Entry {

    public abstract byte[] readClass(String className) throws IOException;

    public abstract String toString();

    public static Entry newEntry(String path) throws IOException {
        if (path.contains(File.pathSeparator)) {
            return new CompositeEntry(path);
        }
        if (path.contains("*")) {
            return new WildcardEntry(path);
        }
        if (path.endsWith(".zip") || path.endsWith(".jar") ||
            path.endsWith(".ZIP") || path.endsWith(".JAR")) {
            return new ZipEntry(path);
        }
        return new DirEntry(path);
    }
}
